package cn.com.qtgl.userfilters.model.pojo;

import cn.com.qtgl.userfilters.model.enums.DepartmentAdapter;
import cn.com.qtgl.userfilters.model.enums.PostAdapter;
import lombok.Getter;

import java.util.List;
import java.util.Objects;

@Getter
public class PositionItem implements Triple{

    private final String department;

    private final DepartmentAdapter departmentAdapter;

    private final String post;

    private final PostAdapter postAdapter;

    public PositionItem(String department, DepartmentAdapter departmentAdapter, String post, PostAdapter postAdapter) {
        this.department = department;
        this.departmentAdapter = departmentAdapter;
        this.post = post;
        this.postAdapter = postAdapter;
    }

    @Override
    public String getBody() {
        return department+departmentAdapter.getFlag()+":"+post+postAdapter.getFlag();
    }

    @Override
    public List<String> getItems() {
        return List.of(department,post);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof PositionItem that)) return false;
        return Objects.equals(getBody(), that.getBody());
    }

    @Override
    public int hashCode() {
        return Objects.hash(getBody());
    }

    @Override
    public String toString() {
        return getBody();
    }
}
